package com.sgb.kjwl.view.ui.adapter.self.publish;

import android.content.Context;
import android.widget.CheckBox;
import android.widget.TextView;

import androidx.appcompat.widget.AppCompatCheckBox;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.GoodsListEntity3;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class GoodsStateAdapter3 extends BaseRecycleAdapter<GoodsListEntity3> {

    private TextView statusView;
    private TextView contentView;
    private TextView priceView;
    private TextView timeView;
    private AppCompatCheckBox check;

    public GoodsStateAdapter3(Context context, List<GoodsListEntity3> datas) {
        super(context, R.layout.item_goods_state3, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final GoodsListEntity3 entity) {
        holder.setBinding(BR.viewModel, entity);
        check = holder.getItem().findViewById(R.id.check);
        statusView = holder.getItem().findViewById(R.id.status_view);
        contentView = holder.getItem().findViewById(R.id.content_view);
        priceView = holder.getItem().findViewById(R.id.price_view);
        timeView = holder.getItem().findViewById(R.id.time_view);
        String status = entity.getStatus();
        if (status.equals("已下架")) {
            statusView.setBackgroundResource(R.drawable.corner2_969696_full_bg);
        } else if (status.equals("已上架")) {
            statusView.setBackgroundResource(R.drawable.corner2_06c764_full_bg);
        }
        if (entity.getCid1().equals("7")) {
            contentView.setText(entity.getStorage());
        } else {
            contentView.setText(entity.getBrandName() + "   | " + entity.getStorage());
        }
        priceView.setText("¥ " + entity.getPriceScope() + "/" + entity.getUnit());
        timeView.setText("更新时间： "+entity.getUpdateTime());
    }

}
